import axios from './commont.js'

export const getAllRoleLlist = () => {
  return axios({
    url: 'roles'
  })
}
// export const getAllRightList = (type) => {
//   return axios({
//     url: `roles/${type}`
//   })
// }

export const deletRole = (id) => {
  return axios({
    method: 'delete',
    url: `roles/${id}`
  })
}

export const changeRole = (id) => {
  return axios({
    method: 'put',
    url: `roles/${id}`
  })
}

export const delRightByrole = (roleId, rightId) => {
  return axios({
    method: 'delete',
    url: `roles/${roleId}/rights/${rightId}`
  })
}

export const grantRightByRole = (roleId, rids) => {
  return axios({
    method: 'post',
    url: `roles/${roleId}/rights`,
    data: { rids }
  })
}
export const addRoles = (data) => {
  return axios({
    method: 'post',
    url: 'roles',
    data
  })
}
